package com.mms.dao;

import org.junit.Test;

import com.mms.entity.User;
import com.mms.entity.UserRole;
import com.mms.util.MD5Utils;
import com.mms.util.MyBatisUtilsPlus;

public class UserMapperTest {

	UserMapper mapper = MyBatisUtilsPlus.getMapper(UserMapper.class);
	
	@Test
	public void testSelectByPrimaryKey() {
		User user = this.mapper.selectByPrimaryKey("becky");
		System.out.println(user);
	}

	@Test
	public void testSelectByUsernameAndPassword() {
		User user = this.mapper.selectByUsernameAndPassword("becky", MD5Utils.md5Password("kaimen"));
		System.out.println(user);
	}

	@Test
	public void testInsert() {
		User user = new User();
		user.setUsername("tina");
		user.setPassword("kaimen");
		user.setEnabled(true);
		user.setManager(null);
		user.setRole(UserRole.USERMANAGER);
		this.mapper.insert(user);
	}

	@Test
	public void testUpdateEnabledByUsername() {
		this.mapper.updateEnabledByUsername("zima", false);	
	}

	@Test
	public void testUpdatePasswordByUsername() {
		this.mapper.updatePasswordByUsername("tina", MD5Utils.md5Password("kaimen"));
	}

}
